using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Pavilion;

namespace Pavilion.Control
{
    public enum Allign
    {
        Left,
        Center,
        Right
    }
    public class Label : Control
    {
        private string text;
        private Color textColor;
        private float textSize;
        private Allign textAllign;

        public Label(string text, Rectangle bounds, Color backgroundColor) : base()
        {
            Text = text;
            AreaBounds = bounds;
            BackgroundColor = backgroundColor;
            TextColor = Color.White;
            TextSize = 0.5f;
            TextAllign = Allign.Center;
        }

        public override void Draw()
        {
            if (!Visible)
                return;

            DrawManager.Instance.FillRectangleOnScreen(ScreenBounds, BackgroundColor);
            DrawManager.Instance.DrawRectangleOnScreen(ScreenBounds, OutlineColor);

            if (TextAllign == Allign.Left)
                DrawManager.Instance.DrawTextOnScreen(text, new Vector2(ScreenBounds.Left + 5, ScreenBounds.Top - 1), TextColor, TextSize, false);
            else
                DrawManager.Instance.DrawTextOnScreen(text, new Vector2(ScreenBounds.Left + ScreenBounds.Width / 2,
                    ScreenBounds.Top + ScreenBounds.Height/2 + 2), TextColor, TextSize, true);

            base.Draw();
        }

        /// <summary>
        /// Gets or Sets the Text of this label.
        /// </summary>
        public string Text
        {
            get { return text; }
            set { text = value; }
        }

        /// <summary>
        /// Gets or sets the size of the text.
        /// </summary>
        public float TextSize
        {
            get { return textSize; }
            set { textSize = value; }
        }

        /// <summary>
        /// Gets or sets the Color of the text.
        /// </summary>
        public Color TextColor
        {
            get { return textColor; }
            set { textColor = value; }
        }

        /// <summary>
        /// Gets or sets the Allignment of the text.
        /// </summary>
        public Allign TextAllign
        {
            get { return textAllign; }
            set { textAllign = value; }
        }
    }
}
